package com.ruoyi.fetv.controller.userController.image;

import com.ruoyi.common.aspect.annotation.AutoDict;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fetv.controller.userController.image.vo.RequestVO;
import com.ruoyi.fetv.controller.userController.image.vo.RespVO;
import com.ruoyi.fetv.domain.FetvImage;
import com.ruoyi.fetv.service.IFetvImageService;
import com.ruoyi.fetv.util.Constant;
import com.ruoyi.fetv.util.Convert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ImageController
 * @Description 用户获取图片的接口
 * @Author 肖润杰
 * @Time 2023/3/9 13:53
 * @Version 1.0
 */
@RestController
@Api(value = "/v1/fetv/image", tags = {"用户获取图片信息"})
@RequestMapping("/v1/fetv/image")
@AutoDict
public class ImageController extends BaseController {
    @Autowired
    private IFetvImageService fetvImageService;

    /**
     * 查询图片列表
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataTypeClass = RequestVO.class, name = "UserImageRequestVO", value = "图片参数", required = true)
    })
    @ApiOperation(value = "查询图片列表", notes = "查询图片列表", httpMethod = "GET")
    @ApiResponse(code = 200, message = "", response = TableDataInfo.class)
    @GetMapping("/images")
    public TableDataInfo<List<FetvImage>> getImages(RequestVO requestVO) {
        startPage();
        FetvImage fetvImage = (FetvImage) Convert.convert(requestVO, FetvImage.class);
        fetvImage.setStatus(Constant.ENABLE);
        List<FetvImage> list = fetvImageService.selectFetvImageList(fetvImage);
        Convert.covertList(list, fetvImage.getClass(), RespVO.class);
        return getDataTable(list);
    }

}
